home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / convertdb / conuser.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.4 KB  |  92 lines

  1. #include <exec/types.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. struct User {
  6.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  7.  USHORT  Slot_Number;
  8.  USHORT  Sec_Status,
  9.      Sec_Board,                   /* File or Byte Ratio */
  10.      Sec_Library,                 /* Ratio              */
  11.      Sec_Bulletin,                /* Computer Type      */
  12.      Messages_Posted;
  13.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  14.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  15.          ConfRead5,  ConfRead6,  ConfRead7,  AccountDate;
  16.  UWORD   ScreenType, Filler1;
  17.  char    Conference_Access[10];
  18.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  19.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  20.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  21.  char    Expert;
  22.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  23.          ConfYM8, ConfYM9;
  24.  long    BeginLogCall;
  25.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  26.  };
  27.  
  28. char username[200];
  29. void sr(char *s);
  30. char newusername[200];
  31. char oldusername[200];
  32. main(int argc,char *argv[])
  33. {
  34.    FILE *fi,*fi2,*fo;
  35.    struct User U;
  36.    struct User N;
  37.    if(argc!=2)
  38.    {
  39.      printf("ConUser version 1.0, written by Joseph Hodge\n");
  40.      printf("usage: ConUser <pathname to userdata>\n");
  41.      printf("   ie: ConUser bbs:User.Data\n");
  42.      printf("\n");
  43.      exit(0);
  44.    }
  45.    strcpy(username,argv[1]);
  46.    sr(username);
  47.    fi=fopen(username,"rb");
  48.    if(fi==NULL)
  49.    {
  50.      printf("Error, can't open %s\n",username);
  51.      printf("\n");
  52.      exit(0);
  53.    }
  54.    strcpy(oldusername,username);
  55.    strcat(oldusername,".old");
  56.    fi2=fopen(oldusername,"rb");
  57.    if(fi2==NULL)
  58.    {
  59.      printf("Error\n");
  60.      fclose(fi);
  61.      exit(0);
  62.    }
  63.    strcat(username,".new");
  64.    fo=fopen(username,"wb");
  65.    while(fread((APTR)&U,sizeof(struct User),1,fi)!=NULL)
  66.    {
  67.      fread((APTR)&N,sizeof(struct User),1,fi2);
  68.      U.Bytes_Download=N.Bytes_Download;
  69.      U.Bytes_Upload=N.Bytes_Upload;
  70.      U.Daily_Bytes_Limit=N.Daily_Bytes_Limit;
  71.      U.Daily_Bytes_Dld=N.Daily_Bytes_Dld;
  72.      U.Uploads=N.Uploads;
  73.      U.Downloads=N.Downloads;
  74.      fwrite((APTR)&U,sizeof(struct User),1,fo);
  75.    }
  76.    fclose(fo);
  77.    fclose(fi);
  78.    fclose(fi2);
  79.    exit(0);
  80. }
  81.  
  82. void sr(char *s)
  83. {
  84.    register int i;
  85.    i=strlen(s)-1;
  86.    while(i>-1)
  87.    {
  88.      if(*(s+i)<=32) *(s+i)='\0'; else break;
  89.      i--;
  90.    }
  91. }
  92.